package com.smmisia.shop.controller;

import com.smmisia.common.Result.Result;
import com.smmisia.shop.request.BusinessRegisterRequest;
import com.smmisia.shop.request.BusinessUpdateRequest;
import com.smmisia.shop.response.BusinessInfoResponse;
import com.smmisia.shop.service.BusinessService;
import com.xxl.job.core.handler.annotation.XxlJob;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/business")
@Tag(name = "商家模块", description = "商家模块")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    @GetMapping("/info")
    @Operation(summary = "商家信息查询")
    public Result<BusinessInfoResponse> info(@RequestParam(value = "id",required = false) Integer id){
        return businessService.info(id);
    }


    /**
     * 商家注册
     * @param request
     * @return
     */
    @PostMapping("/register")
    @Operation(summary = "商家注册")
    public Result<Boolean> register(@Valid @RequestBody BusinessRegisterRequest request){
        return businessService.register(request);
    }

    /**
     * 商家信息修改
     * @param request
     * @return
     */
    @PostMapping("/update")
    @Operation(summary = "商家信息修改")
    public Result<Boolean> update(@Valid @RequestBody BusinessUpdateRequest request){
        return businessService.updateBusiness(request);
    }

    /**
     * 商家营业状态修改
     * @param status
     * @return
     */
    @GetMapping("/status")
    @Operation(summary = "商家营业状态修改")
    public Result<Boolean> updateStatus(@RequestParam("status") Integer status){
        return businessService.updateStatus(status);
    }

    /**
     * 商家注销
     * @return
     */
    @GetMapping("/delete")
    @Operation(summary = "商家删除")
    public Result<Boolean> delete(){
        return businessService.delete();
    }





}
